package com.baor.controller;

import com.baor.domain.HolderEquipmentVO;
import com.baor.service.HolderService;
import com.baor.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/holder")
public class HolderController {

    @Autowired
    private HolderService holderService;

    @RequestMapping("/equipments")
    public ResponseEntity<?> getHolderEquipments(@RequestBody Map<String, Object> params) {
        try {
            List<HolderEquipmentVO> equipments = holderService.getHolderEquipments(params);
            return ResponseEntity.ok(equipments);
        } catch (IllegalArgumentException e) {
            return ResponseEntity.badRequest().body(e.getMessage());
        } catch (Exception e) {
            return ResponseEntity.internalServerError().body("服务器错误: " + e.getMessage());
        }
    }
    @RequestMapping(value = "/monthlyData")
    public R monthlyData(@RequestBody Map<String, Object> params){
        return this.holderService.monthlyData(params);
    }
}